// 移除未使用的导入
// use std::path::Path;
use videoDownloader::converter::{ConverterFactory, ConversionOptions};
use videoDownloader::content_detector::ContentDetector;

fn main() {
    println!("🔍 测试格式检测功能");
    
    // 测试JPEG文件头
    let jpeg_data = [0xFF, 0xD8, 0xFF, 0xE0, 0x00, 0x10, 0x4A, 0x46, 0x49, 0x46];
    let detected_format = ContentDetector::detect_real_format(&jpeg_data);
    println!("JPEG数据检测结果: {}", detected_format);
    
    // 测试PNG文件头
    let png_data = [0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A];
    let detected_format = ContentDetector::detect_real_format(&png_data);
    println!("PNG数据检测结果: {}", detected_format);
    
    // 测试TS文件头
    let mut ts_data = vec![0x47; 188];
    ts_data.extend_from_slice(&[0x47; 188]);
    let detected_format = ContentDetector::detect_real_format(&ts_data);
    println!("TS数据检测结果: {}", detected_format);
    
    // 测试MP4文件头
    let mp4_data = b"\x00\x00\x00\x20ftypiso4";
    let detected_format = ContentDetector::detect_real_format(mp4_data);
    println!("MP4数据检测结果: {}", detected_format);
    
    // 测试未知格式
    let unknown_data = [0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07];
    let detected_format = ContentDetector::detect_real_format(&unknown_data);
    println!("未知数据检测结果: {}", detected_format);
    
    // 测试转换器创建（添加下划线前缀以避免警告）
    let _converter = ConverterFactory::create_ts_converter(1024);
    
    let _options = ConversionOptions {
        output_format: "ts".to_string(),
        quality: None,
        preserve_encoding: true,
        custom_params: Vec::new(),
    };
    
    // 测试根据检测到的格式创建转换器（添加下划线前缀以避免警告）
    let detected_format = ContentDetector::detect_real_format(&ts_data);
    let _converter = match detected_format {
        "ts" => ConverterFactory::create_ts_converter(1024),
        "mp4" => ConverterFactory::create_ts_to_mp4_converter(1024),
        _ => ConverterFactory::create_ts_converter(1024),
    };
    
    let _options = ConversionOptions {
        output_format: detected_format.to_string(),
        quality: None,
        preserve_encoding: true,
        custom_params: Vec::new(),
    };
    
    println!("✅ 格式检测测试完成!");
}